#include <stdio.h>
#include <stdint.h>

typedef int32_t n_type;

n_type find_k(n_type m) {
    int k = 1;
    for(int i = 0; i < 31; i++) {
        int new_k = k << 1;
        if (new_k == m) {
            return new_k;
        }
        if (new_k > m) {
            return k;
        }
        k = new_k;
    }
    return -1;
}

int main(void) {
    int k = 0;
    scanf("%d", &k);
    for(int i = 0; i < k; i++) {
        n_type n;
        scanf("%d", &n);
        int rounds = 0;
        int turns = 0;
        n_type left_people = n;
        while(1) {
            n_type k = find_k(left_people);
            rounds += k / 2;
            if (left_people != 1) {
                turns++;
            }
            left_people -= k / 2;
            if (left_people == 1) {
                break;
            }
        }
        printf("%d %d\n", turns, rounds);
    }
    return 0;
}
